import { AuthTokenService } from './../../common/services/authToken.service';
import { WindowRefService } from './../../common/services/utils/Window.ref.Service';
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
      selector: 'app-head',
      templateUrl: './head.component.html',
      styleUrls: ['./head.component.scss']
})
export class HeadComponent implements OnInit {

      private _window: Window;
      private timeoutTimer: any;
      public taggleSE:boolean = false;

      //获取 外部数据
      @Input() setName: string;
      @Input() isCollapsed: boolean;

      //事件发送器 等待触发
      @Output() collapsed = new EventEmitter();

      constructor(private windowRefService: WindowRefService, private authTokenService: AuthTokenService) {
            this._window = this.windowRefService.nativeWindow;
      }

      ngOnInit() { }

      //折叠侧边栏
      private collapse() {
            this.collapsed.emit();
      }

      // 全屏展示
      fullScreen() {
            this.requestFullScreen(this._window.document.documentElement);
           this.taggleSE = !this.taggleSE;
      }

      fullExit() {
            this.exitFullScreen(this._window.document);
            this.taggleSE = !this.taggleSE;
      }

      private requestFullScreen(element) {

            let requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
            requestMethod.call(element);

      }

      private exitFullScreen(element) {

            let requestMethod = element.cancelFullScreen || element.webkitCancelFullScreen || element.mozCancelFullScreen || element.exitFullScreen
            requestMethod.call(element);

      }

      menuicon() {
            this.collapse();
            this.isCollapsed = !this.isCollapsed;
      }

      //退出
      signOut() {
            this.authTokenService.logout();
      }


}
